-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to emit 'newContract' events #306
Add option to emit 'newContract' events #306
Conversation
Hi @seesemichaelj, thanks for the PR, looks really exciting what you are working on! I am generally positive towards this PR and my first impression is that both naming and implementation makes sense. Want to dig a bit deeper though and also let this sink in for a few days. If someone else from the team (or actually anyone who has a look into this) have some comments, this would be also helpful! Happy real-time debugging! |
Sounds great thanks! |
Hi @seesemichaelj, I now tested this locally within the var vm = new VM({state: stateTrie, emitNewContractEvents: true })
//...
vm.on('newContract', function(object, callback) {
console.log(object)
callback()
}) This works and blocks when I remove the Two thoughs on this, still thinking about the API: |
Thanks @holgerd77 for looking into this! Before responding, I'm going to look into a couple of things. I think I may have misunderstood some things during implementation. It definitely was intended to block. However a cleaner solution would be "only block if someone is listening on that topic." I'll get back to you once I gather some more information on this. |
This is actually really strange: if I comment out Anyway: I think we can't (can we?) really trust this stuff. This actually would be somewhat our desired behavior, but I am not feeling really save on this. |
Here is the Node source code: Not sure how deep one want to dig into that. |
@holgerd77 Eek! My code is written for normal EventEmitter's, but apparently
and the second bullet:
and my code:
😁 I'm going to fix this and get back to you when it's ready for review |
Ok @holgerd77 I have more information now!
As far as your comment: If I add a Without the If I use a I'm not really sure how to proceed on that front; changing it to the below still has the issue, so I don't believe this issue is related to this PR.
|
I went ahead and removed the flag as it's not necessary per my prior comment. Let me know what you think about the other issue (that I think is unrelated), but as far as I'm concerned, this is now ready for re-review. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this works now, tested again locally. Will merge once this minor formatting thing is settled.
I can't promise for dedicated releases for a certain-party-feature-requests, but I will at least take this into account. Do you need this urgently to be released or does this have some time?
README.md
Outdated
@@ -52,6 +52,7 @@ To build for standalone use in the browser, install `browserify` and check [run- | |||
- [`vm.generateGenesis(cb)`](#vmgenerategenesiscb) | |||
- [`VM` debugging hooks](#vm-debugging-hooks) | |||
- [`vm.onStep`](#vmonstep) | |||
- [`newContract` event](#newcontract) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reasons for the inconsistent naming in regards to the vm.onStep
event description title?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I've disagreed with vm.onStep
as it's not a function, so I named it something I felt was more intuitive without changing more than was my realm.
I can make it however you want. vm.onNewContractEvent
to me is just incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also change the title for the onStep event to your format, main thing is in my opinion that it is somewhat consistent.
this update makes the 'events' documentation consistent, accurate, and all-inclusive
@holgerd77 I went ahead and updated the section to be consistent and accurate. Looks like it was missing some extra events in the table of contents part, so I added those as well. Let me know if there are any other requested changes. Thanks! |
@seesemichaelj Thanks, cool, didn't want to be to picky on this - think our README also has other constistency lacks - but this just caught the eye so directly. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks, will merge now. Any comment on the release urgency?
Not urgent. I have one more PR coming to support Velma completely, so I won't be using the official ethereumjs-vm module until that's incorporated as well. From my perspective, you could wait until after that! I should have that PR posted in the next day or two. |
Ok. |
This PR is in support of the new/upcoming Velma Solidity Debugger, which is a real-time (rather than trace analyzer) Solidity debugger with supported VS Code extension.
This PR introduces an option to the
new VM()
API calledemitNewContractEvents
(I am flexible with the name) which will emit an event namednewContract
(also open for name change) which provides a new contract's created address and it's deployment/creation bytecode (for reference/identification of the contract).This event occurs immediately after the address is created for the new contract instance; this allows 3rd party libraries to know about the address before the constructor is executed. For example, this allows
Velma
to stop on breakpoints that are inside the constructor of a contract.I am open for discussion about how this is to be implemented, but being able to know about the address prior to contract instance creation is necessary for
Velma
debugging (specifically for debugging constructors).Let me know if you have any questions or comments! Thanks for the support!!